<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/global.css"/>
		<link rel="stylesheet" type="text/css" href="css/register.css"/>
	</head>
	<body>
		<div class="form-box">
			<h2 class="title">用户登录</h2>
			<form>
				<div class="form-group">
					<input class="kk" type="text" placeholder="用户名" name="username" id="username">
				</div>
				<div class="form-group">
					<input class="kk" type="password" placeholder="密码" name="password" id="password">
				</div>
				<div class="form-group">
					<button id="btnLogin" class="kk" type="button">登录</button>
				</div>
			</form>
			<div style="text-align: center;">
				没有账号，去&nbsp;<a href="register.html">注册</a>
			</div>
		</div>
		<script src="js/jquery.js"></script>
		<script>
			$('#btnLogin').on('click', function(){
				$.ajax({
					url: 'http://localhost:8080/mall/login',
					type: 'POST',
					data: $('form').serialize(),
					dataType: 'json',
					success: function(result) {
						if(result.code == 0) {
							window.location.href = 'index.html';
						} else {
							alert(result.msg);
						}
					}
				});
			});
		</script>
	</body>
</html>
